package com.promise.jokerdream.ui.settings

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.clickable
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.promise.jokerdream.model.currency.CurrencyExchangeAmount
import com.promise.jokerdream.ui.components.SettingCard
import com.promise.jokerdream.ui.components.RoundCheckbox
import com.promise.jokerdream.ui.theme.AppFontSizes
import com.promise.jokerdream.ui.theme.AppSpacing

/**
 * 货币兑换设置卡片
 */
@Composable
fun CurrencyExchangeSettingCard(
    enabled: Boolean,
    onEnabledChange: (Boolean) -> Unit,
    selectedAmount: CurrencyExchangeAmount,
    onAmountChange: (CurrencyExchangeAmount) -> Unit,
    modifier: Modifier = Modifier,
    onExecuteClick: (() -> Unit)? = null
) {
    SettingCard(
        title = "斗豆兑换",
        description = "",
        checked = enabled,
        onCheckedChange = onEnabledChange,
        modifier = modifier,
        onExecuteClick = onExecuteClick,
        content = {
            if (enabled) {
                Row(
                    modifier = Modifier.fillMaxWidth(),
                    horizontalArrangement = Arrangement.spacedBy(AppSpacing.componentLarge),
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    // 100斗豆选项
                    Row(
                        modifier = Modifier
                            .weight(1f)
                            .clickable { onAmountChange(CurrencyExchangeAmount.HUNDRED) }
                            .padding(vertical = AppSpacing.componentSmall),
                        verticalAlignment = Alignment.CenterVertically,
                        horizontalArrangement = Arrangement.spacedBy(AppSpacing.componentMedium)
                    ) {
                        RoundCheckbox(
                            checked = selectedAmount == CurrencyExchangeAmount.HUNDRED,
                            onCheckedChange = { onAmountChange(CurrencyExchangeAmount.HUNDRED) }
                        )
                        
                        androidx.compose.material3.Text(
                            text = "100斗豆",
                            fontSize = AppFontSizes.mediumBody,
                            fontWeight = FontWeight.Medium
                        )
                    }
                    
                    // 500斗豆选项
                    Row(
                        modifier = Modifier
                            .weight(1f)
                            .clickable { onAmountChange(CurrencyExchangeAmount.FIVE_HUNDRED) }
                            .padding(vertical = AppSpacing.componentSmall),
                        verticalAlignment = Alignment.CenterVertically,
                        horizontalArrangement = Arrangement.spacedBy(AppSpacing.componentMedium)
                    ) {
                        RoundCheckbox(
                            checked = selectedAmount == CurrencyExchangeAmount.FIVE_HUNDRED,
                            onCheckedChange = { onAmountChange(CurrencyExchangeAmount.FIVE_HUNDRED) }
                        )
                        
                        androidx.compose.material3.Text(
                            text = "500斗豆",
                            fontSize = AppFontSizes.mediumBody,
                            fontWeight = FontWeight.Medium
                        )
                    }
                }
            }
        }
    )
}
